<?php
namespace App\Service;

use Illuminate\Support\Facades\DB;

class BaseService
{
    //基础类

    protected static $db;
    protected static $dbAdmin = 'admin'; //后台管理员
    protected static $dbVisit = 'user_visit'; //游客
    protected static $dbWx = 'user_wx'; //微信用户
    protected static $dbKehu = 'kehu'; //客户资料
    protected static $dbArea = 'area'; //省市区
    protected static $dbXcxMenu = 'xcx_menu'; //小程序底部菜单
    protected static $dbCate = 'cate'; //分类
    protected static $dbBanner = 'banner'; //轮播图
    protected static $dbAddress = 'user_address'; //收货地址
    protected static $dbConfig = 'config'; //配置
    //商城表
    protected static $dbMallShop = 'mall_shop'; //商城门店
    protected static $dbMallAdmin = 'mall_admin'; //商城门店员工
    protected static $dbMallGoods = 'mall_goods'; //商城商品
    protected static $dbMallGimg = 'mall_gimg'; //商城商品详情图
    protected static $dbMallCart = 'mall_cart'; //商城购物车
    protected static $dbMallOrder = 'mall_order'; //商城订单
    //邀请函
    protected static $dbYqh = 'yqh'; //邀请函
    protected static $dbYqhFlow = 'yqh_flow'; //流程
    protected static $dbYqhUid = 'yqh_uid'; //被邀请人

    protected static $xcxMenus = [
        1 => '商城', '邀请函',
    ];
    protected static $orderStatuss = [
        1 => '待付款', '待发货', '待收货', '待评价', '售后',
    ];

    //连接数据库
    public static function dbConn($db)
    {
        return DB::connection('mysql')->table($db);
    }

    //返还格式
    public static function toback($code = 0, $msg = '', $data = [], $total = 0)
    {
        $msg = $msg ? $msg : '成功';
        return [
            'code' => $code,
            'msg' => $msg,
            'data' => $data,
            'total' => $total,
        ];
    }
}